package service

import (
	"git.oschina.net/fanbuchi/xgggh/sms/model"
	"net/url"
	"net/http"
	"strings"
	"io/ioutil"
)

type LuoSiMaoSendVerify struct {
	Channel *model.Channel
	Sms     *model.Sms
}


func (sendVerify LuoSiMaoSendVerify) SendSms()(body []byte,err error){
	data:=url.Values{}
	data.Set("mobile",sendVerify.Sms.Mobile)
	data.Set("message",sendVerify.Sms.Template)

	httpClient:=http.DefaultClient
	req, err := http.NewRequest("POST", sendVerify.Channel.ApiDomain, strings.NewReader(data.Encode()))
	if err != nil {
		return
	}
	req.SetBasicAuth("api","key-"+sendVerify.Channel.Key)
	req.Header.Set("Content-Type", "application/x-www-form-urlencoded")
	resp, err := httpClient.Do(req)
	if err != nil {
		return nil,err
	}
	defer resp.Body.Close()
	body,err=ioutil.ReadAll(resp.Body)
	return body,err
}



func (sendVerify LuoSiMaoSendVerify) SendEmail()([]byte,error){

	return nil, nil
}

func (sendVerify LuoSiMaoSendVerify) SendVoice()([]byte,error){

	return nil,nil
}